package com.neu.dao;

import com.neu.entity.Admin;

import com.neu.entity.Hire;
import com.neu.entity.Params;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@Repository
public interface AdminDao extends Mapper<Admin> {

    //基于注解的方式
    @Select("select * from admin")
    List<Admin> getUser();

    List<Admin> findBySearch(@Param("params") Params params);

    @Select("select * from admin where name=#{name} limit 1")
    Admin findByName(@Param("name") String name);

    @Select("select * from admin where name=#{name} and password=#{password} limit 1")
    Admin findByNameAndPassword(@Param("name") String name,@Param("password") String password);


    List<Admin> findBySearchTutor(@Param("params") Params params);

    void updateTutor(Admin admin);

    void updatePassword(Admin admin);
    @Select("select phone from admin where name = #{name}")
    String getPhoneByName(Admin admin);
    @Select("select email from admin where name = #{name}")
    String getEmailByName(Admin admin);

    @Select("select admin.*,type.name as typeName from admin  join type on admin.typeId = type.id")
    List<Admin> findAll();

    @Update("update admin set content = #{content} where id = #{id}")
    void updateAdminContent(Admin admin);

    @Update("update admin set content = #{content} where name = #{name}")
    void updateTutorContent(Admin admin);

    @Update("update admin set content = concat(IFNULL(content, ''), #{content}) where id = #{id}")
    void insertTutorContent(Admin admin);

    @Select("select a.* from admin a join hire h on a.id = h.tutorId where h.id = #{id}")
    Admin getTutorInformation(Integer id);

    @Update("update admin set proposal = concat(IFNULL(proposal, ''), #{proposal}) where id = #{id}")
    void proposal(Admin admin);

    @Select("select proposal_score from admin where name = #{name}")
    String findProposal(String name);

    @Update("update admin  set proposal_score = #{proposalScore} where name = #{name}")
    void proposalScore(Admin admin);

    @Select("select proposal_score from admin where name = #{name}")
    String findProposalScore(String name);

    @Update("update admin  set inspect = #{inspect} where id = #{id}")
    void inspect(Admin admin);

    @Select("select inspect from admin where name = #{name}")
    String getInspect(String name);

    @Select("select inspect_score from admin where name = #{name}")
    String getInspectScore(String name);

    @Update("update admin  set inspect_score = #{inspectScore} where name = #{name}")
    void inspectScore(Admin admin);

    @Update("update admin  set paper = #{paper} where id = #{id}")
    void paper(Admin admin);

    @Select("select paper from admin where name = #{name}")
    String getPaper(String name);

    @Select("select paper_score_1 from admin where name = #{name}")
    Float getScore1(Admin admin);

    @Select("select paper_score_2 from admin where name = #{name}")
    Float getScore2(Admin admin);
    @Select("select paper_score_3 from admin where name = #{name}")
    Float getScore3(Admin admin);
    @Select("select paper_score_4 from admin where name = #{name}")
    Float getScore4(Admin admin);
    @Select("select paper_score_5 from admin where name = #{name}")
    Float getScore5(Admin admin);

    @Update("update admin set paper_score_1 = #{paperScore} where name = #{name}")
    void updateScore1(Admin admin);

    @Update("update admin set paper_score_2 = #{paperScore} where name = #{name}")
    void updateScore2(Admin admin);
    @Update("update admin set paper_score_3 = #{paperScore} where name = #{name}")
    void updateScore3(Admin admin);
    @Update("update admin set paper_score_4 = #{paperScore} where name = #{name}")
    void updateScore4(Admin admin);
    @Update("update admin set paper_score_5 = #{paperScore} where name = #{name}")
    void updateScore5(Admin admin);

    @Select("select paper_score_1 from admin where name = #{name}")
    String getPaperScore1(String name);

    @Select("select * from admin where id = #{id}")
    Admin getPersonById(int id);

    @Select("select paper_score_2 from admin where name = #{name}")
    String getPaperScore2(String name);

    @Select("select paper_score_3 from admin where name = #{name}")
    String getPaperScore3(String name);

    @Select("select paper_score_4 from admin where name = #{name}")
    String getPaperScore4(String name);

    @Select("select paper_score_5 from admin where name = #{name}")
    String getPaperScore5(String name);

    @Select("update admin set proposal = #{proposalScoreUrl} where name = #{name}")
    void proposalScoreUrl(Admin admin);

    @Select("select proposal from admin where name = #{name}")
    String getProposalUrl(String name);
}
